home *** CD-ROM | disk | FTP | other *** search
-
- Listing 1.
- ---------
-
- /******************************************************************************
- * BASE.C
- */
-
- #define LINT_ARGS
- #define NOCOMM
- #define NOMINMAX
-
- #include <stdio.h>
- #include <windows.h>
-
- HANDLE hInst; /* Global Instance Handle */
-
- long FAR PASCAL MainFormWndProc(HWND, unsigned, WORD, LONG);
-
- /*****************************************************************************
- * WinMain()
- */
- int PASCAL WinMain(hInstance, hPrevInstance, CmdLine, CmdShow)
- HANDLE hInstance,hPrevInstance;
- LPSTR CmdLine;
- int CmdShow;
- {
- /* WNDCLASS WndClass; REMOVED -- Seems to be redundant -LZ */
- HWND hWnd;
- MSG msg;
-
- hInst=hInstance; /* Store Instance handle */
-
- /*
- * Register Main Form Window Class
- */
- if (!hPrevInstance){
- WNDCLASS WndClass;
- WndClass.lpszClassName = (LPSTR)"base";
- WndClass.hInstance = hInstance;
- WndClass.lpfnWndProc = MainFormWndProc;
- WndClass.style = CS_HREDRAW | CS_VREDRAW;
- WndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
- WndClass.hIcon = NULL;
- WndClass.lpszMenuName = NULL;
- WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
- WndClass.cbClsExtra = NULL;
- WndClass.cbWndExtra = NULL;
- if (!RegisterClass(&WndClass))
- return(NULL);
- }
-
- /*
- * Create MainForm Window
- */
- hWnd = CreateWindow("base", /* window class name */
- "App Template", /* window caption */
- WS_OVERLAPPEDWINDOW, /* window style */
- 0, /* initial x position */
- 0, /* initial y position */
- CW_USEDEFAULT, /* initial x size */
- 0, /* initial y size */
- NULL, /* parent window handle */
- NULL, /* window menu handle */
- hInstance, /* program instance handle */
- NULL); /* create parameters */
- if (!hWnd)
- return (NULL);
- /*
- * Message Loop
- */
- while (GetMessage (&msg,NULL,0,0)){
- TranslateMessage (&msg) ;
- DispatchMessage (&msg) ;
- }
- return (msg.wParam);
- }
- /*****************************************************************************
- * MainFormWndProc()
- */
- long FAR PASCAL MainFormWndProc(hWnd, message, wParam, lParam)
- HWND hWnd;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
- switch (message){
- case WM_SYSCOMMAND:
- if(wParam==SC_MAXIMIZE)
- MessageBox(hWnd,"Intercepted Maximize Message",
- (LPSTR)"App Template",MB_OK);
- if(wParam==SC_MINIMIZE)
- MessageBox(hWnd,"Intercepted Minimize Message",
- (LPSTR)"App Template",MB_OK);
- return(DefWindowProc(hWnd,message,wParam,lParam));
- case WM_CREATE:
- ShowWindow(hWnd,SW_SHOWNORMAL);
- UpdateWindow(hWnd);
- break;
- case WM_ENDSESSION:
- if(MessageBox(hWnd, "This will end the program",
- (LPSTR)"App Template",
- MB_OKCANCEL|MB_ICONEXCLAMATION)==IDCANCEL)
- break;
- DestroyWindow(hWnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:return(DefWindowProc(hWnd,message,wParam,lParam));
- }
- return (NULL);
- }
-
-
-